<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>title</title>
<link rel="stylesheet" href="../assets/agile/css/ratchet/css/ratchet.min.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.component.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.color.css">
<link rel="stylesheet" href="../assets/agile/css/flat/iconline.css">
<link rel="stylesheet" href="../assets/agile/css/flat/iconform.css">
<link rel="stylesheet" href="../assets/app/css/app.css" />
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/local.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<style type="text/css">
.user-listitem-line a{display:block;}
.listitem li{background:#fbfbfb;padding:0 12px;}
.listitem li .text i{vertical-align: sub;}
.listitem li a{padding:12px 0;}
.user-head{background:#fbfbfb;height:110px;poisition:relative;}
.userlevel{width:24px;height:24px;display:block;margin:0 auto;}
.l1{background:url(../image/mobile/new-class-icon.png) no-repeat 0px 0px;}
.l2{background:url(../image/mobile/new-class-icon.png) no-repeat -34px 0px;}
.l3{background:url(../image/mobile/new-class-icon.png) no-repeat -68px 0px;}
.l4{background:url(../image/mobile/new-class-icon.png) no-repeat -100px 0px;}
.l5{background:url(../image/mobile/new-class-icon.png) no-repeat -134px 0px;}
.l6{background:url(../image/mobile/new-class-icon.png) no-repeat -168px 0px;}
</style>
</head>
<body style="background:#F5F5F5;">
<section style="margin-top:0 !important;">
    <div class="create_goods"> 
           <div class="user-head">
				<div class="userlevel" style="position: absolute;top:10px;right:0px;width:55px;hieght:45px;">
					<span class="userlevel"></span>
					<p style="text-align: center;font-size:12px;" class="levelname"></p>
				</div>
               <div class="face">
                   <img src="../image/tavatar.gif"/>
               </div>
               <div class="type_agent" style="display:none;">
               <div style="line-height:15px;color:#777;">代理商：<span style="color:#174884;">加载中...</span></div>
				<p>姓名：<a href="javascript:;">加载中...</a></p>
				<p class="address">所在地：加载中...</p>
               </div>
               <h4 id="username" style="display:none;">未登录</h4>
               <p id="userscore">积分：0</p>
               <p id="userprice">余额：0元</p>
               <button class="btn btn-positive common-btn applyfor" style="float:left;display:none;" onclick="applyfor();"><a href="javascript:;">申请代理商</a></button>
               <button class="btn btn-positive common-btn fansManage" style="float:left;display:none;" onclick="fansManage();"><a href="javascript:;">粉丝管理</a></button>
               <button class="btn btn-positive common-btn" style="float:right;" onclick="javascript:randomSwitchBtn('userrecharge',api);"><a href="javascript:;">充值</a></button>
           </div>
      	
      	<div class="clear"></div>
		<div class="type_agent" style="display:none;">
			<ul class="listitem user-listitem-line">
					<li>
					 <a href="javascript:wxcode();">
						<i class="ricon iconfont iconline-arrow-right"></i>
						<div class="text"><i class="iconfont iconform-barcode"></i>&nbsp;&nbsp;查看代理商二维码</div>
					  </a>
					</li>
			</ul>
			<div class="block5"></div>
		</div>
		<div class="type_member" style="display:none;">
			<ul class="listitem user-listitem-line">
					<li>
					 <a href="javascript:wxcode();">
						<i class="ricon iconfont iconline-arrow-right"></i>
						<div class="text"><i class="iconfont iconform-barcode"></i>&nbsp;&nbsp;查看邀请二维码</div>
					  </a>
					</li>
			</ul>
			<div class="block5"></div>
		</div>
		<ul class="listitem user-listitem-line">
				<li>
				 <a href="javascript:randomSwitchBtn('fxcenter',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-globe1"></i>&nbsp;&nbsp;邀请有奖</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('userbalance',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-file-txt"></i>&nbsp;&nbsp;账户管理</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('userbuylist',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-uid"></i>&nbsp;&nbsp;抢购记录</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('orderlist',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-badge"></i>&nbsp;&nbsp;中奖记录</div>
				  </a>
				</li>
			<li>
			 <a href="javascript:randomSwitchBtnf('z_buyrecord');">
				<i class="ricon iconfont iconline-arrow-right"></i>
				<div class="text"><i class="iconfont iconline-file"></i>&nbsp;&nbsp;直购订单</div>
			  </a>
			</li>
			<li>
			 <a href="javascript:randomSwitchBtnf('z_buyrecord2');">
				<i class="ricon iconfont iconline-arrow-right"></i>
				<div class="text"><i class="iconfont iconline-file"></i>&nbsp;&nbsp;0元购订单</div>
			  </a>
			</li>
			<li>
			 <a href="javascript:randomSwitchBtn('groupdb',api);">
				<i class="ricon iconfont iconline-arrow-right"></i>
				<div class="text"><i class="iconfont iconline-user-group"></i>&nbsp;&nbsp;组团众筹</div>
			  </a>
			</li>

				<li>
					 <a href="javascript:randomSwitchBtn('singlelist',api);">
						<i class="ricon iconfont iconline-arrow-right"></i>
						<div class="text"><i class="iconfont iconline-file"></i>&nbsp;&nbsp;晒单分享</div>
					  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('userfufen',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-share"></i>&nbsp;&nbsp;我的福分</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('basedata',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-setting"></i>&nbsp;&nbsp;个人资料</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:;" onclick="randomSwitchBtn('address_list',api)">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-map-location"></i>&nbsp;&nbsp;收货地址</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('issuelist',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-attach"></i>&nbsp;&nbsp;帮助中心</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('private',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-attach"></i>&nbsp;&nbsp;隐私协议</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('newso',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-heart-fill"></i>&nbsp;&nbsp;服务协议</div>
				  </a>
				</li>
		</ul>
		<!--
		<div class="block5"></div>
		<ul class="listitem user-listitem-line">
				
				<li>
				 <a href="javascript:randomSwitchBtn('invitation',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-share"></i>&nbsp;&nbsp;邀请有奖</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('qiandao',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-handsign"></i>&nbsp;&nbsp;去签到</div>
				  </a>
				</li>
				<li>
				 <a href="javascript:randomSwitchBtn('lottery',api);">
					<i class="ricon iconfont iconline-arrow-right"></i>
					<div class="text"><i class="iconfont iconline-cup-prize"></i>&nbsp;&nbsp;充值抽奖</div>
				  </a>
				</li>
		</ul>
		<div class="block5"></div>
		<ul class="listitem user-listitem-line">
		</ul>
		-->
            <div class="block10"></div>
            <div class="login_status" style="display:none;">
	            <a href="javascript:logout();">
	            <button class="common-btn"style="letter-spacing: 2px;font-size:16px;width:90%;margin: 0 auto;">退出登录</button>
	            </a>
            </div>
            
            <div class="logout_status" style="display:none;">
	            <a href="javascript:login();">
	            <button class="common-btn"style="letter-spacing: 2px;font-size:16px;width:90%;margin: 0 auto;">去登录</button>
	            </a>
            </div>
            
             <div class="block20"></div>
            <p style="text-align:center;">客服电话：<br/>声明：所有商品活动与苹果公司（apple inc.）无关</p>
          
    </div>             
</section>


<script type="text/javascript">
function applyfor(){
	if(!getUserinfo()){
		$.PageDialog.fail('请登录用户');
		return false;
	}
	api.openWin({name:'applyfor','url':'./applyfor.html',reload:true});
}
function randomSwitchBtnf(page){
	if(!getUserinfo()){
		$.PageDialog.fail('请登录用户');
		return false;
	}
	if(page == 'z_buyrecord'){
		localData.set('keyf','jfgoods');
	}else{
		localData.set('keyf','0f');
	}
	api.openWin({name:page,'url':'./'+page+'.html',reload:true});
}
function wxcode(){
	api.openWin({name:'wxcode','url':'./wxcode.html',reload:true});
}
function fansManage(){
	api.openWin({name:'fansmanage','url':'./fansmanage.html',reload:true});
}
apiready = function(){
	api.refreshHeaderLoadDone();
    var header = $api.byId('header');
    if(api.connectionType == 'none'){
        api.showProgress({
             title : '未连接网络',
             text : ''
         });
        return false;
    }else{
        setTimeout(function(){
            api.hideProgress();
        },15000);
    }
    
    if(getUserinfo()){
    	$('.login_status').show();
    }else{
    	$('.logout_status').show();
    }
    
    var timer = setInterval(function(){
    	if(getUserinfo()){
    		if(localData.get('user_is_login') == 'yes'){
    			localData.set('user_is_login','no');
    			window.location.reload();
    		}
    		clearInterval(timer);
    	}
    },1000);

	sb();
	function sb(){
		setTimeout(function(){
			api.refreshHeaderLoadDone();
			sb();
		},15000);
	}
	
	setTimeout(function(){
		api.setRefreshHeaderInfo({
		    visible: true,
		    loadingImg: 'widget://image/refresh.png',
		    bgColor: '#fff',
		    textColor: '#333',
		    textDown: '下拉刷新...',
		    textUp: '松开刷新...',
		    showTime: true
		}, function(ret, err ){
	        //更新余额和积分

	        var userinfo = getUserinfo();
	        $.ajax({
	        	url : config.url+'/app.php?act=updateuser&uid='+userinfo.uid,
	        	dataType:'jsonp',
	        	success : function(data){
					api.refreshHeaderLoadDone();
	        		if(data['status'] == 1){
	        			
	        			if(data['data']['type_agent'] == 'yes'){
	        				$('.type_agent').show();
	        				$('#username').hide();
	        				$('.user-head').css('height','140px');
	        				$('.type_agent div span').text(data['data']['level_name']);
	        				$('.type_agent p a').text(data['data']['truename']?data['data']['truename']:'');
	        				$('.type_agent p.address').text('所在地：'+data['data']['province']+data['data']['city']+data['data']['area']);
	        				$('.fansManage').show();
	        			}else{
							$('.type_member').show();
	        				$('#username').show();
	        				$('.applyfor').show();
	        				$('.user-head').attr('style','height:120px !important');
	        			}
	        	        $('#userprice').html('余额：'+data.data.money+'元');
	        	        $('#userscore').html('积分：'+data.data.score);
	        	        $('.face img').removeAttr('src').addClass('lazy').attr('data-original',config.upload_url+'/'+data.data.thumb);
						$('span.userlevel').removeClass('l1').removeClass('l2').removeClass('l3');
						$('span.userlevel').removeClass('l4').removeClass('l5').removeClass('l6');
						$('span.userlevel').addClass('l'+data['data']['yungoudj_id']);
						$('.levelname').text(data['data']['yungoudj']);
						if(data.data.username){
	        	            us = data.data.username;
	        	        }else if(data.data.mobile){
	        	             us = data.data.mobile;
	        	        }else{
	        	             us = data.data.email;
	        	        }
	        	        $('#username').html(us);
	        	        $('#usersign font').html(data.data.qianming);
	        	        lyzimg();
	        		}else{
	        			api.refreshHeaderLoadDone();
	        	        $('#username').html('<span id="clickLogin">未登录</span>');
	        	        $('#userprice').html('余额：0元');
	        	        $('#userscore').html('积分：0');
	        	        $('#usersign font').html('没错，我就是我~~~');
	        			localData.clear();
	        			$('.user-head').attr('style','height:120px !important');
	        			$('#username').show();
	        			//$.PageDialog.fail(userinfo['msg']);
	        		}
	        	}
	        });
		});
	},500);
	
};

function login(){
	randomSwitchBtn('login',api);
}

//退出用户
function logout(){
	localData.remove('userinfo');
	localData.remove('cart');
	localData.remove('cart_num');
	localData.set('user_is_login','no');
	api.alert({title:'提示',msg:'退出成功'},function(index,error){
		randomSwitchBtn('login',api);
		window.location.reload();
	});
}

//是否登录用户
isLogin();
function isLogin(){
    var userinfo = localData.get('userinfo');
	//var userinfo = jQuery.parseJSON(userinfo);
	var userinfo = JSON.parse(userinfo);
    if(userinfo != undefined && userinfo != '' && userinfo != null){
        if(userinfo.username){
            us = userinfo.username;
        }else if(userinfo.mobile){
             us = userinfo.mobile;
        }else{
             us = userinfo.email;
        }
        
        //更新余额和积分
        $.ajax({
        	url : config.url+'/app.php?act=updateuser&uid='+userinfo.uid,
        	dataType:'jsonp',
        	beforeSend:function(j){//api.showProgress({title:'加载中',text:''});
        	},
        	success : function(userinfo){
        		//api.hideProgress();
        		if(userinfo['status']){
        			if(userinfo['data']['type_agent'] == 'yes'){
        				$('.type_agent').show();
        				$('#username').hide();
        				$('.user-head').css('height','140px');
        				$('.type_agent div span').text(userinfo['data']['level_name']);
        				$('.type_agent p a').text(userinfo['data']['truename']?userinfo['data']['truename']:'');
        				$('.type_agent p.address').text('所在地：'+userinfo['data']['province']+userinfo['data']['city']+userinfo['data']['area']);
        				$('.fansManage').show();
        			}else{
						$('.type_member').show();
        				$('#username').show();
        				$('.applyfor').show();
        				$('.user-head').attr('style','height:120px !important');
        			}
        	        $('#userprice').html('余额：'+userinfo.data.money+'元');
        	        $('#userscore').html('积分：'+userinfo.data.score);
					$('span.userlevel').removeClass('l1').removeClass('l2').removeClass('l3');
					$('span.userlevel').removeClass('l4').removeClass('l5').removeClass('l6');
					$('span.userlevel').addClass('l'+userinfo['data']['yungoudj_id']);
					$('.levelname').text(userinfo['data']['yungoudj']);
					$('.face img').removeAttr('src').addClass('lazy').attr('data-original',config.upload_url+'/'+userinfo.data.thumb);
        	    	lyzimg();
        		}else{
        	        $('#username').html('<span id="clickLogin">未登录</span>');
        	        $('#userprice').html('余额：0元');
        	        $('#userscore').html('积分：0');
        	        $('#usersign font').html('没错，我就是吉祥夺宝~~~');
        			localData.clear();
        			$('#username').show();
        			$('.user-head').attr('style','height:120px !important');
        			$.PageDialog.fail(userinfo['msg']);
        		}
        	}
        });
        
        $('#username').html(us);
        $('#usersign font').html(userinfo.qianming);
        $('.face img').removeAttr('src').addClass('lazy').attr('data-original',config.upload_url+'/'+userinfo.face);
    	lyzimg();    	
    }else{
        $('#username').html('<span id="clickLogin">未登录</span>');
        $('#userprice').html('余额：0元');
        $('#userscore').html('积分：0');
        $('#username').show();
        $('.user-head').attr('style','height:120px !important');
        $('#usersign font').html('没错，我就是吉祥夺宝~~~');
    }
    
    $('.face').click(function(){
        if(!getUserinfo()){
        	randomSwitchBtn('login',api);
        }else{
        	randomSwitchBtn('basedata',api);
        }
    });
    if(getUserinfo()){
    	$('.login_status').show();
    }else{
    	$('.logout_status').show();
    }
}
</script>
</body>
</html>